package com.yjzx.util.common.util.map;

import java.util.*;

/**
 * @author yjzx
 * @create 2023/3/9
 * @Description
 */

public class NodeMap<K,V> {
    private K key;
    private V value;

    public NodeMap() {
    }

    public NodeMap(K key, V value) {
        this.key = key;
        this.value = value;
    }

    public K getKey() {
        return key;
    }

    public void setKey(K key) {
        this.key = key;
    }

    public V getValue() {
        return value;
    }

    public void setValue(V value) {
        this.value = value;
    }

    public static <U,W>NodeMap<U,W> of(U key, W value) {
        return new NodeMap<>(key, value);
    }
    public static <U,W>NodeMap<U,W> of(Map.Entry<U,W> entry) {
        return new NodeMap<>(entry.getKey(), entry.getValue());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        NodeMap<?, ?> nodeMap = (NodeMap<?, ?>) o;
        return Objects.equals(key, nodeMap.key) && Objects.equals(value, nodeMap.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(key, value);
    }

    @Override
    public String toString() {
        return "NodeMap{" +
                "key=" + key +
                ", value=" + value +
                '}';
    }
}
